﻿using Chaoge.LabelInterface;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ChaogePrinter
{
    class Printer
    {

        public void StartPrint()
        {
            //Thread newThread = new Thread(new ParameterizedThreadStart(Print));
            //newThread.SetApartmentState(ApartmentState.STA);
            //newThread.Priority = ThreadPriority.Highest;
            //newThread.Name = "Print-FC";
            //newThread.Start(null);

            Print(null);
        }

        public void Print(object data)
        {
            var app = new LabelApplication();
            //app.Register();

            var pathRed = $"template-red.lbl";
            var pathBlack = $"template.lbl";
            var fsRed = File.OpenRead(pathRed);
            var fsBlack = File.OpenRead(pathBlack);

            app.Template = fsRed;
            app.DataSource = new List<User>() {
                new User(){Id=1, Name="ll"},
                new User(){Id=2, Name="22"}
            };

            app.Print();
        }
    }
    public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
